//
//  GoodsPriceCell.m
//  TerritoryShopkeeper
//
//  Created by xiaowu on 2017/12/12.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "GoodsPriceCell.h"

@implementation GoodsPriceCell
- (void)setValueForCellWithPrice:(NSString *)price notice:(NSString *)notice oldPrice:(NSString *)oldPrice saleCount:(NSString *)saleCount {
    
    NSString *priceStr = [NSString stringWithFormat:@"¥%@", TextIsNotNil(price)?price:@"0"];
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:priceStr];
    [attStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(14)} range:NSMakeRange(0, priceStr.length)];
    [attStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(20)} range:[priceStr rangeOfString:TextIsNotNil(price)?price:@"0.00"]];
    [self.titleLabel setAttributedText:attStr];
    
    self.oldPriceTitleLable.text = @"原价";
    self.oldPriceLabel.text = [NSString stringWithFormat:@"¥%@", TextIsNotNil(oldPrice)?oldPrice:@"0"];
    self.saleCountLabel.text = [NSString stringWithFormat:@"销量%@笔", TextIsNotNil(saleCount)?saleCount:@"0"];
    
//    if (notice.length > 0) {
//        self.noticeLabel.text = notice;
//        self.noticeLabel.hidden = NO;
//    } else {
//        self.noticeLabel.hidden = YES;
//    }
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    self.titleLabel.font = TextPingFangMediumFontSize(20);
    self.titleLabel.textColor = [UIColor redF2color];
    
    self.noticeButton.titleLabel.font = TextPingFangFontSize(13);
    [self.noticeButton setTitleColor:[UIColor gray66Color] forState:UIControlStateNormal];
    self.noticeButton.backgroundColor = [UIColor grayF9Color];
    self.noticeButton.layer.cornerRadius = 2;
    self.noticeButton.layer.borderWidth = 1;
    self.noticeButton.layer.borderColor = [UIColor colorWithHex:0xE8E8E8 alpha:1.0].CGColor;
    [self.noticeButton setTitle:@"降价通知" forState:UIControlStateNormal];
    

    self.oldPriceTitleLable.font = TextPingFangFontSize(12);
    self.oldPriceTitleLable.textColor = [UIColor gray66Color];
    self.oldPriceLabel.font = TextPingFangFontSize(12);
    self.oldPriceLabel.textColor = [UIColor gray66Color];
    self.saleCountLabel.font = TextPingFangFontSize(12);
    self.saleCountLabel.textColor = [UIColor gray66Color];
    self.oldPriceLineView.backgroundColor = [UIColor grayTextColor];
}
- (IBAction)noticeButotnClick:(id)sender {
    if (self.noticeBlock) {
        self.noticeBlock();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
